/**
 * 新增社区 相关云函数
 */
var AV = require('leanengine');
var lean = require('../../../base/lean')
var Community = require('../models/Community')
var Property = require('../models/Property')
var NewCommunity = require('../models/NewCommunity')

/**
 * [云函数编号] 001 - [作用说明]查询社区名称是否重复
 */
AV.Cloud.define('community_find', function(request, response) {
    var communityName = request.params.communityName;
    Community.community_find(communityName,function(data){
        if(data == ''){
            response.success(0)
        }else{
        // 有值 1
            response.success(1)
        }
    })
})

// 模糊查询物业公司
AV.Cloud.define('property_find', function(request, response) {
    var propertyName = request.params.name;
    Property.property_search(propertyName,function(data){
        response.success(data)
    })
});

// 保存所有的新增社区数据
AV.Cloud.define('community_save', function(request,response) {
    var firstStep = request.params.firstStep
    var secondStep = request.params.secondStep
    var thirdStep = request.params.thirdStep

    NewCommunity.newCommunity(firstStep,secondStep,thirdStep,function(data){
        response.success(1)
    })
})
